/**
*    Copyright (C) 2008  Chase Kernan 
*    chase.kernan@gmail.com
*
*    This program is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
**/

package com.chasekernan.hxnova.core.races;

/**
    Enum containing the primary racial traits.
**/
enum PRT {
    HyperExpansion;
    JackOfAllTrades;
}

/**
    Contains all of the data related to the prts. Most of the functions take a
    PRT element and return some sort of data.
**/
class PRTSet {
    
    /**
        The prts are stored here in an ordered set so that the data can also
        be held in arrays.
    **/
    public static var PRT_LIST : Array<PRT> = [HyperExpansion, JackOfAllTrades];
    
    /**
        The point value costs of choosing a prt.
    **/
    public static var COSTS : Array<Int> = [40, -66];
    
    /**
        The description displayed in the race editor.
    **/
    public static var DESCRIPTIONS : Array<String> = ["You must expand to " +
            "survive. You are given a small and cheap colony hull and an " +
            "engine which travels at Warp 6 using no fuel. Your race will " +
            "grow at twice the growth rate you specify; however, the maximum " +
            "population for a given planet is cut in half. The completely " +
            "flexible Meta Morph hull will be available only to your race.", 
            
            "Your race does not specialise in a single area. You start the " +
            "game with Tech 3 in all areas and the components associated with" +
            " those levels are available to you (including a penetrating " +
            "scanner). Your maximum planetary population is 20% greater than " +
            "other races."];
    
    //TODO: Maybe store this as multipliers?
    
    /**
        The maximum population of a star system under each prt.
    **/
    public static var MAX_POPULATIONS : Array<Int> = [500000, 1100000];
    
    /**
        The growth rate modifier for each prt.
    **/
    public static var GROWTH_RATES : Array<Float> = [2.0, 1.0];
    
    public static function getCost(prt : PRT) : Int {
        for(i in 0...PRT_LIST.length) {
            if(PRT_LIST[i] == prt) return COSTS[i];
        }
        
        throw "The prt arrays need to be checked.";
    }
    
    public static function getDescription(prt : PRT) : String {
        for(i in 0...PRT_LIST.length) {
            if(PRT_LIST[i] == prt) return DESCRIPTIONS[i];
        }
        return "";
    }
    
    public static function getPRTByName(name : String) : PRT {
        for(i in PRT_LIST) {
            if(Std.string(i) == name) return i;
        }
        
        throw "No such prt: "+name;
    }
    
    public static function getMaxPop(prt : PRT) : Int {
        for(i in 0...PRT_LIST.length) {
            if(PRT_LIST[i] == prt) return MAX_POPULATIONS[i];
        }
        
        throw "The prt arrays need to be checked.";
    }
    
    public static function getGrowthRate(prt : PRT) : Float {
        for(i in 0...PRT_LIST.length) {
            if(PRT_LIST[i] == prt) return GROWTH_RATES[i];
        }
        
        throw "The prt arrays need to be checked.";
    }
    
}